package com.itheima.common;

import java.util.HashMap;
import java.util.Map;

/**
 * <h1>敏感词实体</h1>
 *
 * @author <a href="515857087@qq.com">叶世铭</a>
 * @since 2022/12/9
 */

public class Trie {
    /**
     * 关键词结束的标识
     */
    private boolean isEnd = false;

    /**
     * 子节点(key 代表下级的节点字符， value是下级节点)
     */
    private Map<Character, Trie> subNode = new HashMap<>();

    public boolean isEnd() {
        return isEnd;
    }

    public void setEnd(boolean end) {
        isEnd = end;
    }

    public Map<Character, Trie> getSubNode() {
        return subNode;
    }

    public void setSubNode(Map<Character, Trie> subNode) {
        this.subNode = subNode;
    }

    public void set(boolean isEnd) {
        this.isEnd = isEnd;
    }

    /**
     * 添加子节点
     *
     * @param key
     * @param subNode
     */
    public void addSubNode(Character key, Trie subNode) {
        this.subNode.put(key, subNode);
    }
}
